package com.heima.handler;


import com.heima.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLIntegrityConstraintViolationException;

/**
 * 全局异常处理器，处理项目中抛出的业务异常
 * @author 赵超
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    /**
     * @param ex
     * @return
     */

    @ExceptionHandler
    public Result exceptionHandler(Exception ex) {
        log.error("所有异常信息：{}", ex.getMessage());
        ex.printStackTrace();
        return Result.error(ex.getMessage());
    }


}
